package com.micro.ai.template.client;

import com.micro.ai.commons.domain.ApiResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Auth服务客户端
 * 用于调用micro-ai-auth模块的服务
 *
 * @author micro-ai
 * @since 0.0.1
 */
@FeignClient(name = "micro-ai-auth", path = "/api")
public interface AuthClient {

    /**
     * 检查用户权限
     *
     * @param userId 用户ID
     * @param permission 权限编码（如：template:create）
     * @return 是否有权限
     */
    @PostMapping("/permissions/check")
    ApiResponse<Boolean> checkPermission(
            @RequestParam("userId") String userId,
            @RequestParam("permission") String permission
    );

    /**
     * 获取用户信息
     *
     * @param userId 用户ID
     * @return 用户信息
     */
    @GetMapping("/users/{userId}")
    ApiResponse<Map<String, Object>> getUserById(@PathVariable("userId") String userId);

    /**
     * 记录审计日志
     *
     * @param auditLog 审计日志信息
     * @return 操作结果
     */
    @PostMapping("/audit/logs")
    ApiResponse<Void> createAuditLog(@RequestBody Map<String, Object> auditLog);

    /**
     * 批量检查用户权限
     *
     * @param userId 用户ID
     * @param permissions 权限列表
     * @return 权限检查结果Map
     */
    @PostMapping("/permissions/batch-check")
    ApiResponse<Map<String, Boolean>> batchCheckPermissions(
            @RequestParam("userId") String userId,
            @RequestBody java.util.List<String> permissions
    );
}

